package com.brk.socket.server;

import io.netty.channel.ChannelHandlerContext;
import lombok.Data;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author brk
 * @date 2023/7/14 15:46
 * @description
 */
public class CustomServerCache {

    private static Map<String, ChannelHandlerContext> map = new ConcurrentHashMap<>();

    public static void save(String clientId, ChannelHandlerContext ctx) {

        if(clientId == null || ctx == null) {
            throw new RuntimeException("客户端连接错误");
        }

        map.put(clientId, ctx);

    }

    public static Map<String, ChannelHandlerContext> getMap() {
        return map;
    }
}
